//
//  MyAccountView.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/28.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "MyAccountView.h"


@interface MyAccountView ()


@property (nonatomic, weak)UIImageView * backImageView;



@property (nonatomic, weak)UILabel * nameLabel;

@property (nonatomic, weak)UILabel * explationLabel;

@property (nonatomic, weak)UILabel * moneyLabel;

@property (nonatomic, weak)UILabel * floatLabel;

@property (nonatomic, weak)UILabel * floatExplationLabel;

@property (nonatomic, weak)UIView * lineView;

@property (nonatomic, weak)UILabel * cleanMoneyLabel;

@property (nonatomic, weak)UILabel * cleanMoneyExplationLabel;


@end

@implementation MyAccountView

- (void)setIconImageString:(NSString *)iconImageString{
    
    _iconImageString = iconImageString;
    
    if ([iconImageString isEqualToString:@""]) {
        
        self.userIconImageView.image = [UIImage imageNamed:@"默认头像"];
    }else{
        
        NSURL * url = [[NSURL alloc] initWithString:iconImageString];
        
        [self.userIconImageView sd_setImageWithURL:url];        
    }
}


- (void)setNameString:(NSString *)nameString{
    
    _nameString = nameString;
    
    self.nameLabel.text = nameString;
}


- (void)setUserMoneyString:(NSString *)userMoneyString{
    
    _userMoneyString = userMoneyString;
    
    self.moneyLabel.text = [NSString stringWithFormat:@"$%@",userMoneyString];
}


- (void)setLoseOrWinString:(NSString *)loseOrWinString{
    
    _loseOrWinString = loseOrWinString;
    
    self.floatLabel.text = loseOrWinString;
}

- (void)setMoneyString:(NSString *)moneyString{
    
    _moneyString = moneyString;
    
    self.cleanMoneyLabel.text = moneyString;
}


- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}



- (void)setupUI{
    
    UIImageView * backImageView = [[UIImageView alloc] init];
    
    backImageView.backgroundColor = [UIColor whiteColor];
    backImageView.image = [UIImage imageNamed:@"我的背景"];
    
    self.backImageView = backImageView;
    
    [self addSubview:self.backImageView];
    
    
    UIImageView * iconImage = [UIImageView new];//WithFrame:CGRectMake(25 * SCREENH6, 27 *
    //默认头像
    iconImage.image = [UIImage imageNamed:@"默认头像"];
    
    iconImage.layer.masksToBounds = YES;
    iconImage.layer.masksToBounds =YES;
    iconImage.layer.cornerRadius = 20 * SCREENH6;
    iconImage.layer.borderWidth= 0;
    iconImage.contentMode = UIViewContentModeScaleAspectFill;
    
    self.userIconImageView = iconImage;
    
    [self addSubview:self.userIconImageView];
    
    
    UILabel * nameLabel = [UILabel new];
    
    nameLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
//    nameLabel.text = @"Angle";
    nameLabel.textColor = ColorWithRGB(0xe3e3e3);
    
    self.nameLabel = nameLabel;
    
    [self addSubview:self.nameLabel];
    
    
    UILabel * explationLabel = [UILabel new];
    
    explationLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    explationLabel.textColor = ColorWithRGB(0xbdbdbd);
    explationLabel.text = @"交易可用资金";
    
    self.explationLabel = explationLabel;
    
    [self addSubview:self.explationLabel];
    
    UILabel * moneyLabel = [UILabel new];
    
    moneyLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:27 * SCREENH6];
    moneyLabel.textColor = ColorWithRGB(0xd43b32);
//    moneyLabel.text = @"$300.88";
    
    self.moneyLabel = moneyLabel;
    
    [self addSubview:self.moneyLabel];
    
    
    UILabel * floatLabel = [UILabel new];
    
    floatLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:21 * SCREENH6];
//    floatLabel.text = @"+10.11";
    floatLabel.textColor = ColorWithRGB(0xe3e3e3);
    
    self.floatLabel = floatLabel;
    
    [self addSubview:self.floatLabel];
    
    
    UILabel * floatExplationLabel = [UILabel new];
    
    floatExplationLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    floatExplationLabel.textColor = ColorWithRGB(0xbdbdbd);
    floatExplationLabel.text = @"浮动盈亏";
    
    self.floatExplationLabel = floatExplationLabel;
    
    [self addSubview:self.floatExplationLabel];
    
    
    UIView * lineView = [[UIView alloc] init];
    
    lineView.backgroundColor = [UIColor whiteColor];
    lineView.alpha = 0.1;
    
    self.lineView = lineView;
    
    [self addSubview:self.lineView];
    
    UILabel * cleanMoneyLabel = [UILabel new];
    
    cleanMoneyLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:21 * SCREENH6];
//    cleanMoneyLabel.text = @"$310.99";
    cleanMoneyLabel.textColor = ColorWithRGB(0xe3e3e3);
    
    self.cleanMoneyLabel = cleanMoneyLabel;
    
    [self addSubview:self.cleanMoneyLabel];
    
    UILabel * cleanMoneyExplationLabel = [UILabel new];
    
    cleanMoneyExplationLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    cleanMoneyExplationLabel.textColor = ColorWithRGB(0xbdbdbd);
    cleanMoneyExplationLabel.text = @"净值";
    
    self.cleanMoneyExplationLabel = cleanMoneyExplationLabel;
    
    [self addSubview:self.cleanMoneyExplationLabel];
}



- (void)layoutSubviews{
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self);
    }];
    
    [self.userIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(25 * SCREENH6);
        make.width.height.mas_equalTo(40 * SCREENH6);
        make.top.mas_equalTo(self).offset(85 * SCREENH6);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.userIconImageView.mas_bottom).offset(- 15 * SCREENH6);
        make.leading.mas_equalTo(self.userIconImageView.mas_trailing).offset(5 * SCREENH6);
    }];
    
    [self.explationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.explationLabel.mas_bottom);
    }];
    
    [self.floatExplationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.floatLabel.mas_bottom);
        make.bottom.mas_equalTo(self.mas_bottom).offset(- 15 * SCREENH6);
//        make.centerX.mas_equalTo(self.floatLabel);
        make.leading.mas_equalTo(self).offset(75 * SCREENH6);
    }];
    
    [self.floatLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.floatExplationLabel);
        make.bottom.mas_equalTo(self.floatExplationLabel.mas_top);
    }];
    
    
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(1 * SCREENH6);
        make.height.mas_equalTo(40 * SCREENH6);
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.floatLabel.mas_top).offset(5 * SCREENH6);
    }];
    
    [self.cleanMoneyExplationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.floatExplationLabel);
//        make.centerX.mas_equalTo(self.cleanMoneyLabel);
        make.leading.mas_equalTo(self.lineView.mas_trailing).offset(75 * SCREENH6);
    }];
    
    [self.cleanMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.floatLabel);
        make.centerX.mas_equalTo(self.cleanMoneyExplationLabel);
//        make.leading.mas_equalTo(self.lineView.mas_trailing).offset(55 * SCREENH6);
    }];
    
   
}




@end
